﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<div id="applydeal">
    <div>
        <input type="button" onclick="doapplyupdate()" value="确定" /></div>
    <div style="padding-top: 35px;">
        <%=Html.Hidden("apply_id", ViewData["apply_id"])%>
        <%=Html.Hidden("sqr_id", ViewData["sqr_id"])%>
        <%=Html.Hidden("czr_id", ViewData["czr_id"])%>
    </div>
    <div>
        开始时间:<%=Html.TextBox("apply_stime", ViewData["apply_stime"], new { @disabled = "disabled" })%>
        结束时间:<%=Html.TextBox("apply_etime", ViewData["apply_etime"], new { @disabled = "disabled" })%>
        申请时间:<%=Html.TextBox("apply_time", ViewData["apply_time"], new { @disabled="disabled"})%><br />
        <br />
        申请事由:<%=Html.TextArea("apply_person", ViewData["apply_person"].ToString(), new {@disabled = "disabled", style = "border: 1px solid #6C92AD;width: 614px;" })%><br />
        <br />
        申请人名:<%=Html.TextBox("sqr_name", ViewData["sqr_name"], new { @disabled = "disabled" })%>
        操作人名:<%=Html.TextBox("czr_name", ViewData["czr_name"], new { @disabled = "disabled" })%>
        <br />
        <br />
        车辆名称:<%=Html.DropDownList("car_id", ViewData["list_car"] as List<SelectListItem>, "---------请选择---------", new { @style = "width:202px; margin-left:8px; padding:0px;border-radius:0px 0px 0px 0px;border:solid 1px #6C92AD;" })%>
        申请结果:<%=Html.DropDownList("apply_result", ViewData["list_result"] as List<SelectListItem>, "---------请选择---------", new { @style = "width:202px; margin-left:8px; padding:0px;border-radius:0px 0px 0px 0px;border:solid 1px #6C92AD;" })%><br />
        <br />
        申请回复:<%=Html.TextArea("apply_reply", ViewData["apply_reply"].ToString(), new {style = "border: 1px solid #6C92AD;width: 614px;" })%></div>
    <div>
        <br />
        冲突条目：
        <table border="0" width="100%" class="table_style" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th class="th_short">
                        申请人
                    </th>
                    <th class="th_middle">
                        申请时间
                    </th>
                    <th class="th_middle">
                        开始时间
                    </th>
                    <th class="th_middle">
                        结束时间
                    </th>
                    <th class="th_short">
                        申请结果
                    </th>
                    <th class="th_middle">
                        操作时间
                    </th>
                    <th>
                    </th>
                </tr>
            </thead>
            <tbody>
                <%
                    System.Data.DataTable dt = ViewData["dt_conflict"] as System.Data.DataTable;
                    if (dt == null || dt.Rows.Count == 0)
                    {%>
                <tr>
                    <td colspan="0" style="text-align: center;">
                        当前无数据！
                    </td>
                </tr>
                <% }
                    else
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                %>
                <tr>
                    <td>
                        <%=dt.Rows[i]["申请人"].ToString()%>
                    </td>
                    <td>
                        <%=dt.Rows[i]["申请时间"].ToString()%>
                    </td>
                    <td>
                        <%=dt.Rows[i]["开始时间"]%>
                    </td>
                    <td>
                        <%=dt.Rows[i]["结束时间"].ToString() %>
                    </td>
                    <td>
                        <% if (dt.Rows[i]["申请结果"].ToString() == "1")
                           {%>同意<%}%>
                        <% if (dt.Rows[i]["申请结果"].ToString() == "-1")
                           {%>未处理<%}%>
                        <% if (dt.Rows[i]["申请结果"].ToString() == "0")
                           {%>驳回<%}%>
                    </td>
                    <td>
                        <%=dt.Rows[i]["操作时间"].ToString() %>
                    </td>
                    <td>
                        <a class="btn_detail" onclick="showApplyDetail('<%=dt.Rows[i]["申请编码"]%>')">详细</a>
                    </td>
                </tr>
                <%
                    }
                    } %>
            </tbody>
        </table>
    </div>
</div>

<script type="text/javascript">

    function doapplyupdate() {
        var apply_id = $("#applydeal #apply_id").val();
        var car_id = $("#applydeal #car_id").val();
        var czr_id = $("#applydeal #czr_id").val();
        var apply_result = $("#applydeal #apply_result").val();
        var apply_reply = $("#applydeal #apply_reply").val();

        if (car_id == null || car_id == "") {
            alert("未选择车辆");
            return;
        }
        if (apply_result == null || apply_result == "") {
            alert("未选择操作结果");
            return;
        }
        $.ajax({
            type: "POST",
            url: "/Car/DoApplyUpdate",
            data: { "apply_id": apply_id, "car_id": car_id, "czr_id": czr_id, "apply_result": apply_result, "apply_reply": apply_reply },
            success: function(restag) {
                if (restag.res != true) {
                    alert(restag.msg);
                }
                else {
                    alert("操作成功");
                    $.fn.deltab('apply-5');
                    $('#menu_applylistall').trigger('click');
                }
            }
        })
    }

    //applyListMy 页下复制过来
    function showApplyDetail(apply_id) {
        $.ajax({
            type: "POST",
            url: "/Car/ApplyDetial",
            data: { "apply_id": apply_id },
            success: function(data) {
                addtab('apply-3', '申请内容');
                $("#workarea-apply-3").html(data);
            }
        })
    }
</script>

